package com.liao.order.controller;

import com.liao.common.entity.order.OrderItemEntity;
import com.liao.common.utils.PageUtils;
import com.liao.order.service.OrderItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 订单商品明细
 *
 * @author liao
 * @email 2858015963@qq.com
 * @date 2025-03-14 09:23:11
 */
@RestController
@RequestMapping("order/orderitem")
public class OrderItemController {
    @Autowired
    private OrderItemService orderItemService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public PageUtils<OrderItemEntity> list(@RequestParam Map<String, Object> params) {
        return orderItemService.queryPage(params);

    }


    /**
     * 信息
     */
    @RequestMapping("/info/{itemId}")
    public OrderItemEntity info(@PathVariable("itemId") Integer itemId) {
        return orderItemService.getById(itemId);

    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public void save(@RequestBody OrderItemEntity orderItem) {
        orderItemService.save(orderItem);
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public void update(@RequestBody OrderItemEntity orderItem) {
        orderItemService.updateById(orderItem);
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public void delete(@RequestBody Integer[] itemIds) {
        orderItemService.removeByIds(Arrays.asList(itemIds));
    }

}
